<!--
 * @Author: your name
 * @Date: 2020-12-19 17:44:01
 * @LastEditTime: 2020-12-19 18:00:58
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \basicjs\event\daili1.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>代理1</title>
</head>
<body>
    <ul>
        <li data-action="hide">houdunren.com</li>
        <li data-action="color" data-color="red">hdcms</li>
    </ul>

    <script>
        class HD{
            constructor(el){
                this.el = el;
                this.el.addEventListener('click',(e)  => {
                    const action = e.target.dataset.action;
                    this[action](e);
                })
            }
            //改变当前元素的颜色
            color(e){
                e.target.style.color = e.target.dataset.color;
            }

            hide(e){
                // e.target.style.display = 'none';
                // e.target.setAttribute('hidden',true);
                e.target.hidden = true;
            }
        }

        new HD(document.querySelector('ul'));
    </script>
</body>
</html>